package com.ruoyi.stock.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock.domain.QwStockmonthinfo;
import com.ruoyi.stock.service.IQwStockmonthinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 股票月信息Controller
 * 
 * @author ruoyi
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/stock/stockmonthinfo")
public class QwStockmonthinfoController extends BaseController
{
    @Autowired
    private IQwStockmonthinfoService qwStockmonthinfoService;

    /**
     * 查询股票月信息列表
     */
    @PreAuthorize("@ss.hasPermi('stock:stockmonthinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwStockmonthinfo qwStockmonthinfo)
    {
        startPage();
        List<QwStockmonthinfo> list = qwStockmonthinfoService.selectQwStockmonthinfoList(qwStockmonthinfo);
        return getDataTable(list);
    }

    /**
     * 导出股票月信息列表
     */
    @PreAuthorize("@ss.hasPermi('stock:stockmonthinfo:export')")
    @Log(title = "股票月信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QwStockmonthinfo qwStockmonthinfo)
    {
        List<QwStockmonthinfo> list = qwStockmonthinfoService.selectQwStockmonthinfoList(qwStockmonthinfo);
        ExcelUtil<QwStockmonthinfo> util = new ExcelUtil<QwStockmonthinfo>(QwStockmonthinfo.class);
        util.exportExcel(response, list, "股票月信息数据");
    }

    /**
     * 获取股票月信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('stock:stockmonthinfo:query')")
    @GetMapping(value = "/{monthInfoId}")
    public AjaxResult getInfo(@PathVariable("monthInfoId") Long monthInfoId)
    {
        return success(qwStockmonthinfoService.selectQwStockmonthinfoByMonthInfoId(monthInfoId));
    }

    /**
     * 新增股票月信息
     */
    @PreAuthorize("@ss.hasPermi('stock:stockmonthinfo:add')")
    @Log(title = "股票月信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwStockmonthinfo qwStockmonthinfo)
    {
        return toAjax(qwStockmonthinfoService.insertQwStockmonthinfo(qwStockmonthinfo));
    }

    /**
     * 修改股票月信息
     */
    @PreAuthorize("@ss.hasPermi('stock:stockmonthinfo:edit')")
    @Log(title = "股票月信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwStockmonthinfo qwStockmonthinfo)
    {
        return toAjax(qwStockmonthinfoService.updateQwStockmonthinfo(qwStockmonthinfo));
    }

    /**
     * 删除股票月信息
     */
    @PreAuthorize("@ss.hasPermi('stock:stockmonthinfo:remove')")
    @Log(title = "股票月信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{monthInfoIds}")
    public AjaxResult remove(@PathVariable Long[] monthInfoIds)
    {
        return toAjax(qwStockmonthinfoService.deleteQwStockmonthinfoByMonthInfoIds(monthInfoIds));
    }
}
